//
//  VIPMallAPI.swift
//  LeGou
//
//  Created by lxm on 2022/8/5.
//
import Foundation

enum VIPMallAPI {
    case category
    // 列表
    case goodsList(_ params : [String : Any])
    // 商品详情
    case goodsDetail(_ id : String)
    // 预xiadan
    case preOrder(_ params : [String : Any])
    // 订单列表
    case orderList(_ params : [String : Any])
    // 加载预下单
    case getPreOrderInfo(_ id : String)
    // 创建订单
    case createOrder(_ params : [String : Any])
    // 订单详情
    case orderDetial(_ id : String)
    // 取消订单
    case cancelOrder(_ params : [String : Any])
    // 获取支付
    case payInfo(_ params : [String : Any])
    // 确认收货
    case suerReceive(_ id : Int)
    // 删除订单
    case deleteOrder(_ id : Int)
    // 查询支付结果zfb
    case alipayCheck(_ orderNo : String)
    // 查询支付结果wx
    case wxCheck(_ orderNo : String)
    // hot
    case hotList(_ params : [String : Any])
    // 提现面板数据
    case walletInfo(_ params : [String : Any])
    // 提现申请
    case withdrawApply(_ params : [String : Any])
    // 创客收益（余额、预估收益、可提现收益）
    case mallIncomeInfo(_ params : [String : Any])
    // 积分商品
    case integralGoods(_ params : [String : Any])
    // 积分明细
    case integralDetail(_ params : [String : Any])
    // 兑换出局额度
    case exchangeQuato(_ params : [String : Any])
    // 兑换落锤次数
    case exchangeHammer(_ params : [String : Any])
    // 获取兑换比例
    case exchangeRatio(_ params : [String : Any])
    // 确认收货地址
    case ensureAddress(_ params : [String : Any])
    // 额度兑换明细
    case quotaExchangeRecord(_ params : [String : Any])
    // 落锤次数兑换明细
    case bidExchangeRecord(_ params : [String : Any])
    // 获取待付尾款数量
    case paymentNum
}

extension VIPMallAPI: ZMApiProvider {
    func BaseUrl() -> String {
        switch self {
            case .integralDetail, .integralGoods:
            return AppHelper.appVerify() ? DEV_BASE_URL : baseUrl
        default:
            break
        }
        return baseUrl
    }
    
    func urlAndMthodAndParam() -> (url: String, method: ZMHTTPMethod, params: [String : Any], body: Bool) {
        switch self {
        case .category:
            return ("/api/front/product/category", .get, [:], false)
        case .goodsList(let pa):
            return ("/api/front/product/list", .get, pa, false)
        case .goodsDetail(let id):
            return ("/api/front/product/detail/\(id)", .get, [:], false)
        case .preOrder(let pa):
            return ("/api/front/order/pre/order", .post, pa, true)
        case .orderList(let pa):
            return ("/api/front/order/list", .get, pa, false)
        case .getPreOrderInfo(let id):
            return ("/api/front/order/load/pre/\(id)", .get, [:], false)
        case .createOrder(let pa):
            return ("/api/front/order/create", .post, pa, true)
        case .orderDetial(let id):
            return ("/api/front/order/detail/\(id)", .get, [:], false)
        case .cancelOrder(let pa):
            return ("/api/front/order/cancel", .post, pa, false)
        case .payInfo(let pa):
            return ("/api/front/pay/payment", .post, pa, true)
        case .suerReceive(let id):
            return ("/api/front/order/take", .post, ["id":id], false)
        case .deleteOrder(let id):
            return ("/api/front/order/del", .post, ["id":id], false)
        case .alipayCheck(let orderNo):
            return ("/api/front/pay/queryAliPayResult", .get, ["orderNo":orderNo], false)
        case .wxCheck(let orderNo):
            return ("/api/front/pay/queryPayResult", .get, ["orderNo":orderNo], false)
        case .hotList(let pa):
            return ("/api/front/product/hot", .get, pa, false)
        case .walletInfo(let pa):
            return ("/api/front/user/mall/extractInfo", .get, pa, false)
        case .withdrawApply(let pa):
            return ("/api/front/user/mall/extractCash", .post, pa, true)
        case .mallIncomeInfo(let pa):
            return ("/api/front/user/ck/incomeInfo", .get, pa, false)
        case .integralGoods(let pa):
            return ("/api/front/product/integral/list", .get, pa, false)
        case .integralDetail(let pa):
            return ("/api/front/user/integral/list", .get, pa, false)
        case .exchangeQuato(let pa):
            return ("/api/front/convert/exchangeQuota", .post, pa, true)
        case .exchangeHammer(let pa):
            return ("/api/front/convert/exchangeBidNum", .post, pa, true)
        case .exchangeRatio(let pa):
            return ("/api/front/convert/getExchangeRatio", .get, pa, false)
        case .ensureAddress(let pa):
            return ("/api/front/order/confirmAddress", .post, pa, true)
        case .quotaExchangeRecord(let pa):
            return ("/api/front/convert/quota/bill/list", .get, pa, false)
        case .bidExchangeRecord(let pa):
            return ("/api/front/convert/bid/bill/list", .get, pa, false)
        case .paymentNum:
            return ("/api/front/ah/getPaymentNum", .get, [:], false)
            
        }
    }
    
    func HTTPHeader() -> ZMHTTPHeaders? {
        return AppHelper.reqeustHeader()
    }
    
    func UpLoadData() -> [Data]? {
        return nil
    }

}
